# Copyright (c) 2012 The Chromium Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import urllib
import webapp2
from google.appengine.api.app_identity import get_application_id


APP_NAME = get_application_id()


class ListRedirect(webapp2.RequestHandler):

  def get(self):
    self.redirect('http://code.google.com/p/chromium/issues/list')


class IssueRedirect(webapp2.RequestHandler):

  def get(self, issue):
    url = 'http://code.google.com/p/chromium/issues/detail?id=%s' % issue
    self.redirect(url)


class UsernameRedirect(webapp2.RequestHandler):

  def get(self, username):
    base = 'http://code.google.com/p/chromium/issues/list'
    query = '?can=2&q=owner:%s&cells=tiles&colspec=' % username
    colspec = 'ID+Pri+Mstone+ReleaseBlock+OS+Area+Feature+Status+Owner+Summary'
    self.redirect(base + query + colspec)


application = webapp2.WSGIApplication(
  [('/',          ListRedirect),
   ('/([0-9]+)',  IssueRedirect),
   ('/~(.*)',     UsernameRedirect),
  ])
